#!/usr/bin/env python

import sys,os
import Options


def build(bld):

    for arch in bld.lst_variants:
        if arch == 'default': continue
        obj = bld.new_task_gen('cc')
        obj.env = bld.env_of_name(arch).copy()
        obj.source = """
        allcodecs.c audioconvert.c bitstream.c bitstream_filter.c dsputil.c eval.c faanidct.c imgconvert.c jrevdct.c opt.c parser.c raw.c resample.c resample2.c simple_idct.c utils.c imgresample.c faandct.c jfdctfst.c jfdctint.c aasc.c ac3enc.c ac3tab.c ac3.c alac.c sp5xdec.c mjpegdec.c mjpeg.c apedec.c asv1.c mpeg12data.c atrac3.c mdct.c fft.c avs.c bethsoftvideo.c bmp.c bmpenc.c c93.c cavs.c cavsdec.c cavsdsp.c golomb.c mpegvideo.c cinepak.c cljr.c cook.c cscd.c cyuv.c dca.c dnxhddec.c dnxhddata.c dnxhdenc.c mpegvideo_enc.c motion_est.c ratecontrol.c dsicinav.c dvbsubdec.c dvbsub.c dvdsubdec.c dvdsubenc.c dv.c 8bps.c 8svx.c escape124.c ffv1.c rangecoder.c huffyuv.c flac.c flacenc.c flicvideo.c h263dec.c h263.c error_resilience.c 4xm.c fraps.c huffman.c gifdec.c lzw.c gif.c h261dec.c h261.c h261enc.c h263_parser.c h264.c h264idct.c h264pred.c h264_parser.c cabac.c idcinvideo.c imc.c indeo2.c indeo3.c dpcm.c interplayvideo.c jpeglsdec.c jpegls.c jpeglsenc.c kmvc.c ljpegenc.c mjpegenc.c loco.c mace.c mimic.c mjpegbdec.c mmvideo.c mpegaudiodec.c mpegaudiodecheader.c mpegaudio.c mpegaudiodata.c mpegaudioenc.c mpc7.c mpc.c mpc8.c mpeg12.c mpeg12enc.c mpeg4video_parser.c msmpeg4.c msmpeg4data.c msrle.c msvideo1.c lcldec.c nellymoserdec.c nuv.c rtjpeg.c pnmenc.c pnm.c pcx.c ptx.c qdm2.c qdrw.c qpeg.c qtrle.c qtrleenc.c ra144.c ra288.c rawdec.c rawenc.c rl2.c roqvideodec.c roqvideo.c roqvideoenc.c elbg.c roqaudioenc.c rpza.c rv10.c sgidec.c sgienc.c rle.c shorten.c smacker.c smc.c snow.c sonic.c sunrast.c svq1dec.c svq1.c svq1enc.c targa.c targaenc.c vp3.c xiph.c vp3dsp.c tiertexseqv.c tiff.c tiffenc.c lzwenc.c truemotion1.c truemotion2.c truespeech.c tscc.c tta.c txd.c s3tc.c ulti.c vb.c vc1.c vc1data.c vc1dsp.c intrax8.c intrax8dsp.c vcr1.c vmdav.c vmnc.c vorbis_dec.c vorbis.c vorbis_data.c vorbis_enc.c vp5.c vp56.c vp56data.c vp6.c vqavideo.c wavpack.c wmadec.c wma.c wmaenc.c wmv2dec.c wmv2.c wmv2enc.c wnv1.c ws-snd1.c xan.c xl.c xsubdec.c lclenc.c pcm.c adpcm.c adxdec.c adxenc.c g726.c mpeg4audio.c aac_parser.c aac_ac3_parser.c ac3_parser.c cavs_parser.c dca_parser.c dvbsub_parser.c dvdsub_parser.c h261_parser.c mjpeg_parser.c mlp_parser.c mpegaudio_parser.c mpegvideo_parser.c pnm_parser.c vc1_parser.c dump_extradata_bsf.c h264_mp4toannexb_bsf.c imx_dump_header_bsf.c mjpega_dump_header_bsf.c movsub_bsf.c mp3_header_compress_bsf.c mp3_header_decompress_bsf.c noise_bsf.c remove_extradata_bsf.c pthread.c
       """
        if arch == 'arm': obj.source += ' armv4l/dsputil_arm.c armv4l/mpegvideo_arm.c armv4l/jrevdct_arm.S armv4l/simple_idct_arm.S armv4l/dsputil_arm_s.S'

 
        obj.includes     = obj.env['FFMPEG_SUBDIRS_INCLUDES']
        obj.name         = 'avcodec_'+arch
        #obj.target = 'avcodec'
        obj.env.append_unique('CPPFLAGS', obj.env['FFMPEG_SUBDIRS_ADDITIONALFLAGS'])

